 <?php require_once ADMINVIEWPATH.'admin_header.php'; ?>
<?php require_once ADMINVIEWPATH.'admin_menu.php'; ?>
 <link href="<?= STATICURL; ?>css/bootstrap.min.css" rel="stylesheet" />
    <link id="bootstrap-rtl-link" href="" rel="stylesheet" />
    <link id="beyond-link" href="<?= STATICURL; ?>css/beyond.min.css" rel="stylesheet" type="text/css" />
    <style>
        input[type=radio] {
            position:static;
            opacity: 1;
        }
    </style>
    <div class="page-content">
     <!-- Page Breadcrumb -->
        <div class="page-breadcrumbs">
            <ul class="breadcrumb">
                <li>
                    <i class="fa fa-home"></i>
                    <a href="/luckydog/index">首页</a>
                </li>
                <li class="">
                    <a href="/luckydog/news/index">新闻列表</a>
                </li>
                <li class="active">
                    用户图片答题列表
                </li>
            </ul>
        </div>
        <!-- /Page Breadcrumb -->
        <div class="page-body">
        <div style="float: left;">
                <div class="control-group"  style="float: left; padding-left:10px;margin-bottom: 30px;">
                    <div class="controls" >
                        <select id="questionType" style="width: 150px;">
                                <option value = "">--请选择类型--</option>
                                <option value = "1">单选</option>
                                <option value = "2">填空</option>
                                <option value = "3">选图</option>
                        </select>
                    </div>
                </div>
                <div style="float: left;">
                    <a class="btn J_search" href="javascript:;">搜索</a>
                </div>
                <div class="widget-title"> <span class="icon"><i class="icon-th"></i></span>
            <div >
                <div id="horizontal-form">
				<?php if($questionList):?>
                <?php foreach ($questionList as $key => $question):?>
                    <div class="row question_place">
                        <div class="col-md-12">
                            <label>Q<?=($key+1)?>：<?=$question['questionTitle']?>&nbsp;&nbsp;<i style="color:blue;"><?=$question['single_question_point']?>积分</i>&nbsp;&nbsp;<i style="color:blue;"><?=$question['single_question_money']?>元奖金</i></label>
                            
                            <?php if($question['questionType'] == 1):?>
                                <?php foreach ($question['options'] as $opkey => $option):?>
                                <div >
                                    <label>
                                        <input type="radio" name=""  <?php if($question['answer'] == ($opkey+1)):?>checked="checked"<?php else:?>disabled="disabled"<?php endif;?> />
                                        <span style="<?php if(($question['answer']) == $opkey+1):?>color:red;<?php endif;?>"><?=$option['optionTitle']?></span>
                                    </label>
                                </div>
                                <?php endforeach;?>
                                  <div class="pull-right" style="line-height: 100px;">
                                        <?php if($question['isright'] == 1):?>
                                            <span style="color:green;">正确</span>
                                        <?php elseif($question['isright'] == -1):?>
                                            <span style="color:red;">错误</span>
                                        <?php endif;?>
                                </div>
                            <?php elseif ($question['questionType'] == 2):?>
                                <div class="pull-left">
                                <label>
                                    <input type="text" name="title" disabled="disabled"  class="form-control" value="<?=$question['answer']?>"><br />答案：<i style="color:green;"><?=$question['answer']?></i>
                                </label>
                                </div>
                                <div class="pull-right" style="line-height: 100px;">
                                        <?php if($question['isright'] == 1):?>
                                            <span style="color:green;">正确</span>
                                        <?php elseif($question['isright'] == -1):?>
                                            <span style="color:red;">错误</span>
                                        <?php endif;?>
                                </div>
                            <?php elseif ($question['questionType'] == 3):?>
                                <div>
                                    <div class="pull-left">
                                        答案：
                                        <a href="<?= OSSHOST.$question['right_answer']?>" target="_blank">
                                            <img width="200" height="100" src="<?= OSSHOST.$question['right_answer']?>">
                                        </a>
                                    </div>
                                    <div class="pull-left">
                                        用户<?=$question['AccountID']?>答案：
                                        <a href="<?= OSSHOST.$question['answer']?>" target="_blank"><img width="200" height="100" src="<?= OSSHOST.$question['answer']?>"></a>
                                    </div>
                                    <div class="pull-left" style="margin-left: 10px;line-height: 100px;">
                                        <?=$question['Createtime']?>
                                    </div>
                                    <div data_answerid="<?=$question['answerID']?>" data_accountid="<?=$question['AccountID']?>" data_qid="<?=$question['questionID']?>" data_newsid="<?=$question['newsID']?>"  class="pull-right" style="line-height: 100px;">
                                        <?php if($question['isright'] == 0):?>
                                        <a data_isright="1" class="js_isright">正确</a>|<a class="js_isright" data_isright="-1">错误</a>
                                        <?php elseif($question['isright'] == 1):?>
                                            <span style="color:green;">正确</span>
                                        <?php elseif($question['isright'] == -1):?>
                                            <span style="color:red;">错误</span>
                                        <?php endif;?>
                                    </div>
                                </div>
                            <?php endif;?>
                            <div class="horizontal-space"></div>
                        </div>
                    </div>
                    <hr/>
                <?php endforeach;?>
                <div class="page_links"><?= $page_links?></div>
				<?php else:?>
				<div class="row" style="text-align:center;">暂时没有数据</div>
				<?php endif;?>
                </div>
            </div>
        </div>
<?php require_once ADMINVIEWPATH.'admin_footer.php'; ?>
<script>
$(".J_search").click(function(){
        var questionType = $("#questionType").val();
        var params={
            'questionType':questionType
        };
        location = "/luckydog/examination/questionAll?"+$.param(params);
    });
$(".js_isright").on("click",function(){
    var questionID = $(this).parent().attr("data_qid");
    var newsID = $(this).parent().attr("data_newsid");
    var isright = $(this).attr("data_isright");
    var AccountID = $(this).parent().attr("data_accountid");
    var answerID = $(this).parent().attr("data_answerid");
    if(questionID == "" || newsID=="" || AccountID == "" || answerID=="")
    {
        layer.msg('参数错误');
        return false;
    } 
    if (confirm("确定判断吗")) {
        $.post("/luckydog/examination/estimate",{answerID:answerID,AccountID:AccountID,questionID:questionID,newsID:newsID,isright:isright,},function(data){
            if(data.code == 200)
            {
                layer.msg("成功");
                window.location.reload();
            }else{
                layer.msg(data.data.message);
            }
        },"json");
    }
    
});
$('.edit_question').on('click', function(){
        //iframe窗
        var id = "<?=$id?>";
        var title = "修改";
        if(id == undefined){
            id = "";
            title = "添加";
        }
        layer.open({
            type: 2,
            title: title,
            shade: [0.5, '#000'],
            shadeClose: false,
            maxmin: true, //开启最大化最小化按钮
            area: ['550px', '360px'],
            content: '/luckydog/examination/editques?id='+id
        });
    });
	$("#all_question_point").bind({
            keyup:function(){
                 var txt = $("#all_question_point").val();
                 var reg = /^[\d]+$/;
                 if(!reg.test(txt) ){
                        $(this).val('');
                 }
            },
            focus:function(){
                if ($(this).val() == 0){
                    $(this).val('');
                }
            },
            blur:function(){
                if ($(this).val() == ''){
                    $(this).val(default_order);
                }                   
            }
    }); 
    $("#all_question_money").bind({
            keyup:function(){
                 var txt = $("#all_question_money").val();
                 var reg = /^[\d]+$/;
                 if(!reg.test(txt) ){
                        $(this).val('');
                 }
            },
            focus:function(){
                if ($(this).val() == 0){
                    $(this).val('');
                }
            },
            blur:function(){
                if ($(this).val() == ''){
                    $(this).val(default_order);
                }                   
            }
    }); 
	$("#js_publish").click(function() {
    var id = "<?=$id?>";
    var activity_endtime = $("#activity_endtime").val();
    var all_question_point = $("#all_question_point").val();
    var all_question_money = $("#all_question_money").val();
    if(activity_endtime == "")
    {
        layer.msg("活动结束时间不能为空");
        return false;
    }
    var confirm_show = "发布试题后将不允许改动,请确认:\n"
                       +"全部答对时可获得积分："+all_question_point+"\n"
                       +"全部答对时可获得奖金："+all_question_money+"\n"
                       +"活动答题截止日期："+activity_endtime+"\n"
                       +"确定发布试题吗？";
    if (confirm(confirm_show)) {
        $.post("/luckydog/examination/publish", {"id":id,all_question_point:all_question_point,activity_endtime:activity_endtime,all_question_money:all_question_money}, function(res) {
            if (res) {
				layer.msg("发布成功");
               // window.location.reload();
            }else{
                layer.msg("发布失败");
            }
        });
    }
});
$(".js_del").click(function() {
    var id = $(this).attr("data_id");
    if (confirm("您确定要删除该吗？")) {
        $.post("/luckydog/examination/delete", {"id":id}, function(res) {
            if (res) {
                window.location.reload();
            }else{
                alert("删除失败");
            }
        });
    }
});
$(".question_place").hover(function(){
    $(this).find(".js_del").show();
},function(){
    $(this).find(".js_del").hide();
});

</script>